<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import type { ComponentSize } from 'element-plus'
import { OrdersModel } from '../assets/model/Orders';
import { receiveOrder } from '../assets/net/NetUtils';
import { userInfoStore } from '../assets/userStore/userStore';

const userStore = userInfoStore();
const fill = ref<boolean>(true)
const size = ref<ComponentSize>('default')
const finishList = ref<Array<OrdersModel>>()

onMounted(() => {
    receiveOrder(userStore.uid)
        .then((value) => {
            finishList.value = value.data as Array<OrdersModel>
        })
})
</script>

<template>
    <el-scrollbar height="100%" style="overflow-y: hidden;width: 100%;">
        <el-row style="width: 100%;" justify="center" align="middle">
            <el-col :span="24"><el-text style="font-size: large;">已收货</el-text></el-col>
            <el-col :span="24" style="margin-top: 1%;">
                <el-space wrap :size="size" :fill="fill" style="width: 100%;">
                    <div v-for="item in finishList" :key="item.oid">
                        <el-card shadow="hover" style="height: auto;">
                            <el-row style="width: 100%;">
                                <el-col :span="24">
                                    <el-row justify="space-between">
                                        <el-col :span="21"><el-text>订单编号：{{ item.oid }}</el-text></el-col>
                                        <el-col :span="3"><el-tag type="success">状态：已签收</el-tag></el-col>
                                    </el-row>
                                </el-col>
                                <el-col :span="24">
                                    <el-divider></el-divider>
                                </el-col>
                                <el-col :span="24">
                                    <el-row justify="space-between" style="width: 100%;">
                                        <el-text style="font-size: large;">购买商品：{{
                                            item.commodity?.commodityName }}</el-text>
                                        <el-text style="color: red;">交易金额：¥{{ item.price }}</el-text>
                                    </el-row>
                                </el-col>
                            </el-row>
                        </el-card>
                    </div>
                </el-space>
            </el-col>
        </el-row>
    </el-scrollbar>
</template>